package com.gui.employee.mapper;

import com.gui.employee.consts.EmployeeConst;
import com.gui.employee.entity.EmployeeDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.jdbc.SQL;

import java.util.List;

@Mapper
public interface EmployeeMapper {

    @SelectProvider(method = "selectByEmpNo", value = Provider.class)
    public EmployeeDO getByEmpNo(Integer empNo);


    @SelectProvider(method = "queryEmployeeList", value = Provider.class)
    public List<EmployeeDO> queryEmployeeList();



    class Provider{

        public String selectByEmpNo(Integer empNo){
            SQL sql = new SQL();
            sql.SELECT("*");
            sql.FROM(EmployeeConst.EMPLOYEE_TABLE_NAME);
            sql.WHERE(String.format("emp_no = %d", empNo));
            return sql.toString();
        }


        public String queryEmployeeList() {
            SQL sql = new SQL();
            sql.SELECT("*");
            sql.FROM(EmployeeConst.EMPLOYEE_TABLE_NAME);
            sql.WHERE("last_name = 'Swan'");
            return sql.toString();
        }
    }

}
